// src/api/productCategoryAPI.js
import http from '@/utils/http'

/**
 * 添加商品类目信息
 * @param {Object} params - 类目信息对象
 */
export const addProductCategoryAPI = (params) => {
  return http.post('/product-client/cms/productCategoryInfo/add', params)
}

/**
 * 修改商品类目资料
 * @param {number} id - 类目ID
 * @param {Object} params - 类目信息对象
 */
export const updateProductCategoryAPI = (id, params) => {
  return http.post(`/product-client/cms/productCategoryInfo/update?id=${id}`, params)
}

/**
 * 删除商品类目
 * @param {number} id - 类目ID
 */
export const deleteProductCategoryAPI = (id) => {
  return http.post(`/product-client/cms/productCategoryInfo/delete?id=${id}`)
}

/**
 * 获取商品类目详情
 * @param {number} id - 类目ID
 */
export const getProductCategoryAPI = (id) => {
  return http.post(`/product-client/cms/productCategoryInfo/get?id=${id}`)
}

/**
 * 切换类目状态
 * @param {number} id - 类目ID
 */
export const toggleCategoryStatusAPI = (id) => {
  return http.post(`/product-client/cms/productCategoryInfo/toggleStatus?id=${id}`)
}

/**
 * 根据商品类目名称模糊匹配
 * @param {string} name - 类目名称
 */
export const searchProductCategoryByNameAPI = (name) => {
  return http.post('/product-client/cms/productCategoryInfo/searchByName', {}, {
    params: {
      name: name || undefined
    }
  })
}

/**
 * 获取所有商品类目信息
 */
export const listAllProductCategoriesAPI = () => {
  return http.post('/product-client/cms/productCategoryInfo/listAll')
}